package com.quectel.constant.core.scheduling;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * @author zhangheng
 * @email nolan.zhang@quectel.com
 * @date 2023/7/5 13:52
 * @description new java file header...
 */
public class SchedulingLeaveConstants {


    /**
     * 长期有效结束时间
     */
    public static final String LONG_TERM_TIME = "9999-12-31 23:59:59";
    public static final String EXACT_START_TIME = "exactStartTime";
    public static final String EXACT_END_TIME = "exactEndTime";

    public static final String QUERY_START_TIME = "queryStartTime";
    public static final String QUERY_END_TIME = "queryEndTime";

    public static final String IS_TIME_CROSSED = "isTimeCrossed";

    public static final String RECYCLE_DATE = "recycleDate";
    /**
     * 假期默认小数长度
     */
    public static final int DEFAULT_SCALE = 2;

    /**
     * 假期使用规则时长限制
     */
    @AllArgsConstructor
    public enum LeaveTypeEnum {
        /**
         * 年假
         */
        ANNUAL_LEAVE((byte) 1,"{\"type\":1,\"minUnit\":4,\"calTimeLengthType\":1,\"limitFlag\":1,\"grantRuleJson\":null,\"usageRuleJson\":null,\"status\":0,\"typeName\":null,\"grantRule\":{\"method\":1,\"periodType\":1,\"period\":\"01-1\",\"newEmployeeDiscount\":1,\"grantStandard\":1,\"combinedGrant\":{\"fixedAmount\":null,\"totalLimit\":null,\"companyResultConfig\":{\"breakpoints\":[{\"threshold\":1,\"result\":0},{\"threshold\":5,\"result\":5},{\"threshold\":15,\"result\":10},{\"threshold\":20,\"result\":15}],\"maxResult\":15},\"workResultConfig\":{\"breakpoints\":[{\"threshold\":1,\"result\":0},{\"threshold\":2,\"result\":0}],\"maxResult\":0}},\"roundingRule\":2,\"effectiveType\":1,\"effectiveNum\":1,\"effectiveUnit\":4,\"effectiveExtendNum\":3,\"effectiveExtendNumUnit\":3},\"usageRule\":{\"evidenceFlag\":0,\"evidenceRemark\":null,\"singleMinTimeLimit\":0,\"singleMinTime\":{\"num\":null,\"unit\":4,\"periodUnit\":null},\"singleMaxTimeLimit\":0,\"singleMaxTime\":{\"num\":null,\"unit\":4,\"periodUnit\":null},\"accumulatedMaxTimeLengthLimit\":0,\"accumulatedMaxTimeLength\":[{\"num\":null,\"unit\":4,\"periodUnit\":null}],\"submitTimeLimitType\":0,\"submitTimeLimit\":{\"num\":null,\"unit\":6,\"periodUnit\":null},\"qualificationLimitType\":0,\"qualificationLimit\":{\"num\":null,\"unit\":6,\"periodUnit\":null}}}"),
        /**
         * 婚假
         */
        MARRIAGE_LEAVE((byte) 2,"{\"type\":2,\"minUnit\":4,\"calTimeLengthType\":1,\"limitFlag\":0,\"grantRuleJson\":null,\"usageRuleJson\":null,\"status\":0,\"typeName\":null,\"grantRule\":{\"method\":null,\"periodType\":null,\"period\":null,\"newEmployeeDiscount\":0,\"grantStandard\":null,\"combinedGrant\":{\"fixedAmount\":null,\"totalLimit\":null,\"companyResultConfig\":{\"breakpoints\":[{\"threshold\":1,\"result\":0},{\"threshold\":2,\"result\":0}],\"maxResult\":0},\"workResultConfig\":{\"breakpoints\":[{\"threshold\":1,\"result\":0},{\"threshold\":2,\"result\":0}],\"maxResult\":0}},\"roundingRule\":null,\"effectiveType\":null,\"effectiveNum\":null,\"effectiveUnit\":null,\"effectiveExtendNum\":null,\"effectiveExtendNumUnit\":null},\"usageRule\":{\"evidenceFlag\":1,\"evidenceRemark\":\"请上传半年内的结婚证明\",\"singleMinTimeLimit\":0,\"singleMinTime\":{\"num\":null,\"unit\":4,\"periodUnit\":null},\"singleMaxTimeLimit\":1,\"singleMaxTime\":{\"num\":240,\"unit\":4,\"periodUnit\":null},\"accumulatedMaxTimeLengthLimit\":0,\"accumulatedMaxTimeLength\":[{\"num\":null,\"unit\":4,\"periodUnit\":null}],\"submitTimeLimitType\":0,\"submitTimeLimit\":{\"num\":null,\"unit\":6,\"periodUnit\":null},\"qualificationLimitType\":0,\"qualificationLimit\":{\"num\":null,\"unit\":6,\"periodUnit\":null}}}"),

        /**
         * 产假
         */
        MATERNITY_LEAVE((byte) 3,"{\"type\":3,\"minUnit\":4,\"calTimeLengthType\":1,\"limitFlag\":0,\"grantRuleJson\":null,\"usageRuleJson\":null,\"status\":0,\"typeName\":null,\"grantRule\":{\"method\":null,\"periodType\":null,\"period\":null,\"newEmployeeDiscount\":0,\"grantStandard\":null,\"combinedGrant\":{\"fixedAmount\":null,\"totalLimit\":null,\"companyResultConfig\":{\"breakpoints\":[{\"threshold\":1,\"result\":0},{\"threshold\":2,\"result\":0}],\"maxResult\":0},\"workResultConfig\":{\"breakpoints\":[{\"threshold\":1,\"result\":0},{\"threshold\":2,\"result\":0}],\"maxResult\":0}},\"roundingRule\":null,\"effectiveType\":null,\"effectiveNum\":null,\"effectiveUnit\":null,\"effectiveExtendNum\":null,\"effectiveExtendNumUnit\":null},\"usageRule\":{\"evidenceFlag\":1,\"evidenceRemark\":\"请上传结婚证、生育证或准生证\",\"singleMinTimeLimit\":0,\"singleMinTime\":{\"num\":null,\"unit\":4,\"periodUnit\":null},\"singleMaxTimeLimit\":1,\"singleMaxTime\":{\"num\":3792,\"unit\":4,\"periodUnit\":null},\"accumulatedMaxTimeLengthLimit\":0,\"accumulatedMaxTimeLength\":[{\"num\":null,\"unit\":4,\"periodUnit\":null}],\"submitTimeLimitType\":0,\"submitTimeLimit\":{\"num\":null,\"unit\":6,\"periodUnit\":null},\"qualificationLimitType\":0,\"qualificationLimit\":{\"num\":null,\"unit\":6,\"periodUnit\":null}}}"),
        /**
         * 陪产假
         */
        PATERNITY_LEAVE((byte) 4,"{\"type\":4,\"minUnit\":4,\"calTimeLengthType\":1,\"limitFlag\":0,\"grantRuleJson\":null,\"usageRuleJson\":null,\"status\":0,\"typeName\":null,\"grantRule\":{\"method\":null,\"periodType\":null,\"period\":null,\"newEmployeeDiscount\":0,\"grantStandard\":null,\"combinedGrant\":{\"fixedAmount\":null,\"totalLimit\":null,\"companyResultConfig\":{\"breakpoints\":[{\"threshold\":1,\"result\":0},{\"threshold\":2,\"result\":0}],\"maxResult\":0},\"workResultConfig\":{\"breakpoints\":[{\"threshold\":1,\"result\":0},{\"threshold\":2,\"result\":0}],\"maxResult\":0}},\"roundingRule\":null,\"effectiveType\":null,\"effectiveNum\":null,\"effectiveUnit\":null,\"effectiveExtendNum\":null,\"effectiveExtendNumUnit\":null},\"usageRule\":{\"evidenceFlag\":1,\"evidenceRemark\":\"请上传结婚证、准生证或出生证明材料\",\"singleMinTimeLimit\":0,\"singleMinTime\":{\"num\":null,\"unit\":4,\"periodUnit\":null},\"singleMaxTimeLimit\":1,\"singleMaxTime\":{\"num\":360,\"unit\":4,\"periodUnit\":null},\"accumulatedMaxTimeLengthLimit\":0,\"accumulatedMaxTimeLength\":[{\"num\":null,\"unit\":4,\"periodUnit\":null}],\"submitTimeLimitType\":0,\"submitTimeLimit\":{\"num\":null,\"unit\":6,\"periodUnit\":null},\"qualificationLimitType\":0,\"qualificationLimit\":{\"num\":null,\"unit\":6,\"periodUnit\":null}}}"),

        /**
         * 丧假
         */
        BEREAVEMENT_LEAVE((byte) 5,"{\"type\":5,\"minUnit\":4,\"calTimeLengthType\":1,\"limitFlag\":0,\"grantRuleJson\":null,\"usageRuleJson\":null,\"status\":0,\"typeName\":null,\"grantRule\":{\"method\":null,\"periodType\":null,\"period\":null,\"newEmployeeDiscount\":0,\"grantStandard\":null,\"combinedGrant\":{\"fixedAmount\":null,\"totalLimit\":null,\"companyResultConfig\":{\"breakpoints\":[{\"threshold\":1,\"result\":0},{\"threshold\":2,\"result\":0}],\"maxResult\":0},\"workResultConfig\":{\"breakpoints\":[{\"threshold\":1,\"result\":0},{\"threshold\":2,\"result\":0}],\"maxResult\":0}},\"roundingRule\":null,\"effectiveType\":null,\"effectiveNum\":null,\"effectiveUnit\":null,\"effectiveExtendNum\":null,\"effectiveExtendNumUnit\":null},\"usageRule\":{\"evidenceFlag\":0,\"evidenceRemark\":null,\"singleMinTimeLimit\":0,\"singleMinTime\":{\"num\":null,\"unit\":4,\"periodUnit\":null},\"singleMaxTimeLimit\":1,\"singleMaxTime\":{\"num\":72,\"unit\":4,\"periodUnit\":null},\"accumulatedMaxTimeLengthLimit\":0,\"accumulatedMaxTimeLength\":[{\"num\":null,\"unit\":4,\"periodUnit\":null}],\"submitTimeLimitType\":0,\"submitTimeLimit\":{\"num\":null,\"unit\":6,\"periodUnit\":null},\"qualificationLimitType\":0,\"qualificationLimit\":{\"num\":null,\"unit\":6,\"periodUnit\":null}}}"),

        /**
         * 事假
         */
        CASUAL_LEAVE((byte) 6,"{\"type\":6,\"minUnit\":4,\"calTimeLengthType\":1,\"limitFlag\":0,\"grantRuleJson\":null,\"usageRuleJson\":null,\"status\":0,\"typeName\":null,\"grantRule\":{\"method\":null,\"periodType\":null,\"period\":null,\"newEmployeeDiscount\":0,\"grantStandard\":null,\"combinedGrant\":{\"fixedAmount\":null,\"totalLimit\":null,\"companyResultConfig\":{\"breakpoints\":[{\"threshold\":1,\"result\":0},{\"threshold\":2,\"result\":0}],\"maxResult\":0},\"workResultConfig\":{\"breakpoints\":[{\"threshold\":1,\"result\":0},{\"threshold\":2,\"result\":0}],\"maxResult\":0}},\"roundingRule\":null,\"effectiveType\":null,\"effectiveNum\":null,\"effectiveUnit\":null,\"effectiveExtendNum\":null,\"effectiveExtendNumUnit\":null},\"usageRule\":{\"evidenceFlag\":0,\"evidenceRemark\":null,\"singleMinTimeLimit\":0,\"singleMinTime\":{\"num\":null,\"unit\":4,\"periodUnit\":null},\"singleMaxTimeLimit\":0,\"singleMaxTime\":{\"num\":null,\"unit\":4,\"periodUnit\":null},\"accumulatedMaxTimeLengthLimit\":0,\"accumulatedMaxTimeLength\":[{\"num\":null,\"unit\":4,\"periodUnit\":null}],\"submitTimeLimitType\":0,\"submitTimeLimit\":{\"num\":null,\"unit\":6,\"periodUnit\":null},\"qualificationLimitType\":0,\"qualificationLimit\":{\"num\":null,\"unit\":6,\"periodUnit\":null}}}"),

        /**
         * 事假
         */
        SICK_LEAVE((byte) 7,"{\"type\":7,\"minUnit\":4,\"calTimeLengthType\":1,\"limitFlag\":0,\"grantRuleJson\":null,\"usageRuleJson\":null,\"status\":0,\"typeName\":null,\"grantRule\":{\"method\":null,\"periodType\":null,\"period\":null,\"newEmployeeDiscount\":0,\"grantStandard\":null,\"combinedGrant\":{\"fixedAmount\":null,\"totalLimit\":null,\"companyResultConfig\":{\"breakpoints\":[{\"threshold\":1,\"result\":0},{\"threshold\":2,\"result\":0}],\"maxResult\":0},\"workResultConfig\":{\"breakpoints\":[{\"threshold\":1,\"result\":0},{\"threshold\":2,\"result\":0}],\"maxResult\":0}},\"roundingRule\":null,\"effectiveType\":null,\"effectiveNum\":null,\"effectiveUnit\":null,\"effectiveExtendNum\":null,\"effectiveExtendNumUnit\":null},\"usageRule\":{\"evidenceFlag\":1,\"evidenceRemark\":\"请上传医生开的病假证明 \",\"singleMinTimeLimit\":0,\"singleMinTime\":{\"num\":null,\"unit\":4,\"periodUnit\":null},\"singleMaxTimeLimit\":0,\"singleMaxTime\":{\"num\":null,\"unit\":4,\"periodUnit\":null},\"accumulatedMaxTimeLengthLimit\":0,\"accumulatedMaxTimeLength\":[{\"num\":null,\"unit\":4,\"periodUnit\":null}],\"submitTimeLimitType\":0,\"submitTimeLimit\":{\"num\":null,\"unit\":6,\"periodUnit\":null},\"qualificationLimitType\":0,\"qualificationLimit\":{\"num\":null,\"unit\":6,\"periodUnit\":null}}}"),

        /**
         * 哺乳假
         */
        BREASTFEEDING_LEAVE((byte) 8,"{\"type\":8,\"minUnit\":4,\"calTimeLengthType\":1,\"limitFlag\":0,\"grantRuleJson\":null,\"usageRuleJson\":null,\"status\":0,\"typeName\":null,\"grantRule\":{\"method\":null,\"periodType\":null,\"period\":null,\"newEmployeeDiscount\":0,\"grantStandard\":null,\"combinedGrant\":{\"fixedAmount\":null,\"totalLimit\":null,\"companyResultConfig\":{\"breakpoints\":[{\"threshold\":1,\"result\":0},{\"threshold\":2,\"result\":0}],\"maxResult\":0},\"workResultConfig\":{\"breakpoints\":[{\"threshold\":1,\"result\":0},{\"threshold\":2,\"result\":0}],\"maxResult\":0}},\"roundingRule\":null,\"effectiveType\":null,\"effectiveNum\":null,\"effectiveUnit\":null,\"effectiveExtendNum\":null,\"effectiveExtendNumUnit\":null},\"usageRule\":{\"evidenceFlag\":1,\"evidenceRemark\":\"请上传小孩的出生证明    \",\"singleMinTimeLimit\":0,\"singleMinTime\":{\"num\":null,\"unit\":4,\"periodUnit\":null},\"singleMaxTimeLimit\":0,\"singleMaxTime\":{\"num\":0,\"unit\":4,\"periodUnit\":null},\"accumulatedMaxTimeLengthLimit\":1,\"accumulatedMaxTimeLength\":[{\"num\":1,\"unit\":4,\"periodUnit\":1}],\"submitTimeLimitType\":0,\"submitTimeLimit\":{\"num\":null,\"unit\":6,\"periodUnit\":null},\"qualificationLimitType\":0,\"qualificationLimit\":{\"num\":null,\"unit\":6,\"periodUnit\":null}}}"),

        /**
         * 育儿假
         */
        PARENTAL_LEAVE((byte) 9,"{\"type\":9,\"minUnit\":4,\"calTimeLengthType\":1,\"limitFlag\":1,\"grantRuleJson\":null,\"usageRuleJson\":null,\"status\":0,\"typeName\":null,\"grantRule\":{\"method\":1,\"periodType\":1,\"period\":\"01-1\",\"newEmployeeDiscount\":0,\"grantStandard\":5,\"combinedGrant\":{\"fixedAmount\":240,\"totalLimit\":null,\"companyResultConfig\":{\"breakpoints\":[{\"threshold\":1,\"result\":0},{\"threshold\":2,\"result\":0}],\"maxResult\":0},\"workResultConfig\":{\"breakpoints\":[{\"threshold\":1,\"result\":0},{\"threshold\":2,\"result\":0}],\"maxResult\":0}},\"roundingRule\":1,\"effectiveType\":1,\"effectiveNum\":1,\"effectiveUnit\":4,\"effectiveExtendNum\":0,\"effectiveExtendNumUnit\":1},\"usageRule\":{\"evidenceFlag\":1,\"evidenceRemark\":\"请上传小孩的出生证明\",\"singleMinTimeLimit\":0,\"singleMinTime\":{\"num\":null,\"unit\":4,\"periodUnit\":null},\"singleMaxTimeLimit\":1,\"singleMaxTime\":{\"num\":12,\"unit\":4,\"periodUnit\":null},\"accumulatedMaxTimeLengthLimit\":0,\"accumulatedMaxTimeLength\":[{\"num\":null,\"unit\":4,\"periodUnit\":null}],\"submitTimeLimitType\":0,\"submitTimeLimit\":{\"num\":null,\"unit\":6,\"periodUnit\":null},\"qualificationLimitType\":0,\"qualificationLimit\":{\"num\":null,\"unit\":6,\"periodUnit\":null}}}"),

        /**
         * 调休假
         */
        COMPENSATORY_LEAVE((byte) 10,"{\"type\":10,\"minUnit\":4,\"calTimeLengthType\":1,\"limitFlag\":1,\"grantRuleJson\":null,\"usageRuleJson\":null,\"status\":0,\"typeName\":null,\"grantRule\":{\"method\":3,\"periodType\":null,\"period\":null,\"newEmployeeDiscount\":0,\"grantStandard\":null,\"combinedGrant\":{\"fixedAmount\":null,\"totalLimit\":null,\"companyResultConfig\":{\"breakpoints\":[{\"threshold\":1,\"result\":0},{\"threshold\":2,\"result\":0}],\"maxResult\":0},\"workResultConfig\":{\"breakpoints\":[{\"threshold\":1,\"result\":0},{\"threshold\":2,\"result\":0}],\"maxResult\":0}},\"roundingRule\":2,\"effectiveType\":2,\"effectiveNum\":null,\"effectiveUnit\":3,\"effectiveExtendNum\":0,\"effectiveExtendNumUnit\":1},\"usageRule\":{\"evidenceFlag\":0,\"evidenceRemark\":null,\"singleMinTimeLimit\":0,\"singleMinTime\":{\"num\":null,\"unit\":4,\"periodUnit\":null},\"singleMaxTimeLimit\":0,\"singleMaxTime\":{\"num\":null,\"unit\":4,\"periodUnit\":null},\"accumulatedMaxTimeLengthLimit\":0,\"accumulatedMaxTimeLength\":[{\"num\":null,\"unit\":4,\"periodUnit\":null}],\"submitTimeLimitType\":0,\"submitTimeLimit\":{\"num\":null,\"unit\":6,\"periodUnit\":null},\"qualificationLimitType\":0,\"qualificationLimit\":{\"num\":null,\"unit\":6,\"periodUnit\":null}}}"),

        ;
        @Getter
        private final Byte type;
        @Getter
        private final String template;

        public static LeaveTypeEnum getByType(Byte type) {
            for (LeaveTypeEnum typeEnum : LeaveTypeEnum.values()) {
                if (typeEnum.getType().equals(type)) {
                    return typeEnum;
                }
            }
            return null;
        }


    }


    /**
     * 假期使用规则时长限制
     */
    @AllArgsConstructor
    public enum SubmitTimeLimitEnum {
        /**
         * 不限制
         */
        NOT_LIMIT((byte) 1),
        /**
         * 最晚在休假开始时间前几天申请
         */
        BEFORE_START_TIME((byte) 2),

        /**
         * 最晚在休假结束时间后几天申请
         */
        AFTER_END_TIME((byte) 3),

        ;
        @Getter
        private final Byte type;
    }

    /**
     * 假期使用规则时长限制
     */
    @AllArgsConstructor
    public enum TimeLimitTypeEnum {
        /**
         * 不限制
         */
        NOT_LIMIT((byte) 1),
        /**
         * 固定额度
         */
        FIX((byte) 2),

        /**
         * 周期范围限制
         */
        PERIOD((byte) 3),

        ;
        @Getter
        private final Byte type;
    }

    /**
     * 计算请假时长方式
     */
    @AllArgsConstructor
    public enum CalLeaveTimeLenghTypeEnum {
        /**
         * 工作日
         */
        WORK_DAY((byte) 1),
        /**
         * 自然日
         */
        NATURE_DAY((byte) 2),

        ;
        @Getter
        private final Byte type;

        public static CalLeaveTimeLenghTypeEnum getByType(Byte unit) {
            for (CalLeaveTimeLenghTypeEnum typeEnum : CalLeaveTimeLenghTypeEnum.values()) {
                if (typeEnum.getType().equals(unit)) {
                    return typeEnum;
                }
            }
            return null;
        }
    }


    /**
     * 时长单位 自然时长
     * 对应的是SchedulingLeaveEffectiveTimeUnit
     */
    @AllArgsConstructor
    public enum PeriodTimeUnitEnum {
        /**
         * 天 00:00~23:59
         */
        DAY((byte) 1),
        /**
         * 周一到周日
         */
        WEEK((byte) 2),
        /**
         * 每月初到月底
         */
        MONTH((byte) 3),
        /**
         * 1月1日~12月31日
         */
        YEAR((byte) 4),
        ;

        @Getter
        private final Byte unit;

        public static PeriodTimeUnitEnum getByUnit(Byte unit) {
            for (PeriodTimeUnitEnum typeEnum : PeriodTimeUnitEnum.values()) {
                if (typeEnum.getUnit().equals(unit)) {
                    return typeEnum;
                }
            }
            return null;
        }
    }

    @AllArgsConstructor
    public enum TimeUnitEnum {
        /**
         * 毫秒
         */
        MS((byte) 1, 1),
        /**
         * 一秒的毫秒数
         */
        SECOND((byte) 2, 1000),
        /**
         * 一分钟的毫秒数
         */
        MINUTE((byte) 3, SECOND.getMillis() * 60),
        /**
         * 一小时的毫秒数
         */
        HOUR((byte) 4, MINUTE.getMillis() * 60),
        /**
         * 半天的毫秒数
         */
        HALF_DAY((byte) 5, HOUR.getMillis() * 12),
        /**
         * 一天的毫秒数
         */
        DAY((byte) 6, HOUR.getMillis() * 24),
        ;

        @Getter
        private final Byte unit;

        @Getter
        private final long millis;

        public static TimeUnitEnum getByUnit(Byte unit) {
            for (TimeUnitEnum typeEnum : TimeUnitEnum.values()) {
                if (typeEnum.getUnit().equals(unit)) {
                    return typeEnum;
                }
            }
            return null;
        }

        /**
         * 单位换算
         *
         * @param num        换算数值
         * @param originUnit 原单位
         * @param targetUnit 目标单位
         * @return 返回换算后的数值
         */
        public static BigDecimal changeUnit(BigDecimal num, Byte originUnit, Byte targetUnit) {
            if (originUnit.equals(targetUnit)) {
                return num;
            } else {
                SchedulingLeaveConstants.TimeUnitEnum originUnitEnum = SchedulingLeaveConstants.TimeUnitEnum.getByUnit(originUnit);
                SchedulingLeaveConstants.TimeUnitEnum targetUnitEnum = SchedulingLeaveConstants.TimeUnitEnum.getByUnit(targetUnit);
                if (originUnitEnum == null || targetUnitEnum == null) {
                    return null;
                } else {
                    return num.multiply(BigDecimal.valueOf(originUnitEnum.getMillis())).divide(BigDecimal.valueOf(targetUnitEnum.getMillis()), SchedulingLeaveConstants.DEFAULT_SCALE, RoundingMode.HALF_UP);
                }
            }
        }
    }


    public static final String QUERY_DATE = "queryDate";

    /**
     * 假期发放方式
     */
    @AllArgsConstructor
    public enum GrantMethodEnum {
        /**
         * 按年
         */
        YEAR((byte) 1),
        /**
         * 按月
         */
        MONTH((byte) 2),

        /**
         * 加班时长自动转换为假期余额
         */
        AUTO_CONVERT((byte) 3),
        ;
        @Getter
        private final Byte method;
    }

    /**
     * 假期发放标准
     */
    @AllArgsConstructor
    public enum GrantStandardEnum {
        /**
         * 按照司龄发放
         */
        COMPANY_AGE((byte) 1),
        /**
         * 按照工龄发放
         */
        WORKING_AGE((byte) 2),

        /**
         * 按照工龄发放与司龄发放的较大值
         */
        MAX_AGE((byte) 3),

        /**
         * 按照工龄发放和司龄发放之和
         */
        SUM_AGE((byte) 4),

        /**
         * 固定值
         */
        FIXED((byte) 5),

        ;
        @Getter
        private final Byte type;
    }

    /**
     * 假期发放方式
     */
    @AllArgsConstructor
    public enum GrantPeriodTypeEnum {
        /**
         * 自定义时间
         */
        CUSTOM_TIME((byte) 1),
        /**
         * 入职时间
         */
        ENTRY_TIME((byte) 2),


        ;
        @Getter
        private final Byte type;
    }


    /**
     * 假期发放方式
     */
    @AllArgsConstructor
    public enum RoundingRuleEnum {
        /**
         * 默认 不取整
         */
        ROUND_UNNECESSARY((byte) 1, BigDecimal.ROUND_UNNECESSARY),
        /**
         * 四舍五入
         */
        ROUND_HALF_UP((byte) 2, BigDecimal.ROUND_HALF_UP),
        /**
         * 向上取整
         */
        ROUND_CEILING((byte) 3, BigDecimal.ROUND_CEILING),
        /**
         * 向下取整
         */
        ROUND_FLOOR((byte) 4, BigDecimal.ROUND_FLOOR),

        ;
        @Getter
        private final Byte type;
        @Getter
        private final int roundType;

        public static RoundingRuleEnum getByType(Byte type) {
            for (RoundingRuleEnum roundingRuleEnum : RoundingRuleEnum.values()) {
                if (roundingRuleEnum.getType().equals(type)) {
                    return roundingRuleEnum;
                }
            }
            return null;
        }

        public static BigDecimal getRoundValue(RoundingRuleEnum ruleEnum, BigDecimal bigDecimal) {
            if (ROUND_UNNECESSARY.equals(ruleEnum)) {
                return bigDecimal;
            } else {
                return bigDecimal.setScale(0, ruleEnum.roundType);
            }
        }
    }

    /**
     * 假期有效期类型
     */
    @AllArgsConstructor
    public enum EffectiveTypeEnum {
        /**
         * 按照发放日期失效
         */
        ISSUE_DAY((byte) 1),
        /**
         * 自然周期
         */
        NATURE((byte) 2),
        /**
         * 永久有效
         */
        PERMANENT((byte) 3),

        ;
        @Getter
        private final Byte type;
    }


}
